﻿<%@ Page Title="-" Language="C#" MasterPageFile="~/Administration/MasterPage.master" AutoEventWireup="true" CodeFile="Detail.aspx.cs" Inherits="Administration_Hosts_Detail" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CPHMain" runat="Server">
    <altairis:AutoModeFormView ID="AutoModeFormView1" runat="server" DataKeyNames="HostId" DataSourceID="LinqDataSource1" DefaultMode="Edit" DefaultRedirectUrl="Default.aspx" InsertPageTitle="New Host" EditPageTitle="Edit Host">
        <InsertItemTemplate>
            <table class="form">
                <tbody>
                    <tr>
                        <th>
                            <asp:Label ID="Label1" runat="server" Text="Host name:" AssociatedControlID="HostNameTextBox" />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="HostNameTextBox" ErrorMessage="Host name is missing" Text="*" Display="Dynamic" />
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="HostNameTextBox" ValidationExpression="[a-z0-9-]+(\.[a-z0-9-]+)*" ErrorMessage="Host name syntax invalid" Text="*" Display="Dynamic" />
                            <asp:CustomValidator runat="server" ControlToValidate="HostNameTextBox" Display="Dynamic" ErrorMessage="Host name already taken" Text="*" OnServerValidate="HostNameTextBox_ServerValidate" />
                        </th>
                        <td>
                            <asp:TextBox ID="HostNameTextBox" runat="server" Text='<%# Bind("HostName") %>' Width="500px" />
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <asp:Label ID="Label2" runat="server" Text="Owning user:" AssociatedControlID="UserNameDropDownList" />
                        </th>
                        <td>
                            <asp:DropDownList ID="UserNameDropDownList" runat="server" SelectedValue='<%# Bind("UserName") %>' DataSourceID="UsersDataSource1" DataTextField="UserName" DataValueField="UserName" Width="500px" />
                            <altairis:UsersDataSource ID="UsersDataSource1" runat="server" />
                        </td>
                    </tr>
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="2">
                            <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
                            <asp:Button ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Submit" />
                            <asp:Button ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                        </td>
                    </tr>
                </tfoot>
            </table>
        </InsertItemTemplate>
        <EditItemTemplate>
            <table class="form">
                <tbody>
                    <tr>
                        <th>Date created:</th>
                        <td>
                            <span class="strong" style="float: right">
                                <altairis:IconLinkButton runat="server" Icon="LinkDelete" CommandName="Delete" CausesValidation="false" AlternateText="Delete this host" ID="IconLinkButton1" />
                                <ajax:ConfirmButtonExtender ID="IconLinkButton1_ConfirmButtonExtender" runat="server" ConfirmText="Are you sure you want to delete this host name and all related data?" Enabled="True" TargetControlID="IconLinkButton1" />
                                <asp:LinkButton runat="server" CommandName="Delete" CausesValidation="false" Text="Delete this host" ID="LinkButton1" />
                                <ajax:ConfirmButtonExtender ID="LinkButton1_ConfirmButtonExtender" runat="server" ConfirmText="Are you sure you want to delete this host name and all related data?" Enabled="True" TargetControlID="LinkButton1" />
                            </span>
                            <altairis:DateLabel ID="DateLabel1" runat="server" DateValue='<%# Eval("DateCreated") %>' />
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <asp:Label ID="Label1" runat="server" Text="Host name:" />
                        </th>
                        <td>
                            <asp:Label ID="HostNameLabel" runat="server" Text='<%# Eval("HostName") %>' CssClass="code" />
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <asp:Label ID="Label2" runat="server" Text="Owning user:" AssociatedControlID="UserNameDropDownList" />
                        </th>
                        <td>
                            <asp:DropDownList ID="UserNameDropDownList" runat="server" SelectedValue='<%# Bind("UserName") %>' DataSourceID="UsersDataSource1" DataTextField="UserName" DataValueField="UserName" Width="500px" />
                            <altairis:UsersDataSource ID="UsersDataSource1" runat="server" />
                        </td>
                    </tr>
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="2">
                            <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
                            <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Submit" />
                            <asp:Button ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                        </td>
                    </tr>
                </tfoot>
            </table>
        </EditItemTemplate>
    </altairis:AutoModeFormView>
    <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="SwitchboardDataContext" EnableDelete="True" EnableInsert="True" EnableUpdate="True" TableName="Hosts" Where="HostId == @HostId">
        <WhereParameters>
            <asp:QueryStringParameter Name="HostId" QueryStringField="HostId" Type="Int32" />
        </WhereParameters>
    </asp:LinqDataSource>
</asp:Content>
